<template>
    <div class="home-swipe">
        <van-search v-model="search" input-align="center" @search="onSearch" shape="round" placeholder="搜索" />
        <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
            <van-swipe-item v-for="(item, index) in bannerData" :key="index">
                <van-image lazy-load :src="item.picUrl" radius="20"/>
            </van-swipe-item>
        </van-swipe>
    </div>
</template>

<script>
import { Toast } from 'vant';
// import axios from 'axios';
export default {
    data() {
        return {
            search: "",
            bannerData: []
        };
    },
    methods: {
        getBanner() {
            //     axios.get("/api/recommend/banner")
            //     .then((response) => {
            //         console.log(response.data)
            //         let resData = response.data;
            //         if(resData.result == 100){
            //            this.bannerData = resData.data
            //         }
            //     })
            //     .catch(function (error){
            //         console.log(error);
            //     })
            this.$request('get', '/recommend/banner')
                .then(res=>{
                    // console.log(res)
                    if(res.result == 100) {
                        this.bannerData = res.data
                    }
                })
        },

        onSearch(val) {
            Toast(val)
        }
    },
    created() {
        this.getBanner();
    },
    mounted() {

    }
}
</script>

<style scoped>

</style>